/******************************************************************************

  Copyright (C), 2001-2021, 3snic Tech. Co., Ltd.

 ******************************************************************************
  File Name     : nic_cfg_comm.h
  Version       : Initial Draft
  Description   : nic config common header file
  Function List :
  History       :
    Modification: Created file

******************************************************************************/

#ifndef SSSNIC_CFG_COMM_H
#define SSSNIC_CFG_COMM_H

/* rss */
#define SSSNIC_RSS_TYPE_VALID_SHIFT 23
#define SSSNIC_RSS_TYPE_TCP_IPV6_EXT_SHIFT 24
#define SSSNIC_RSS_TYPE_IPV6_EXT_SHIFT 25
#define SSSNIC_RSS_TYPE_TCP_IPV6_SHIFT 26
#define SSSNIC_RSS_TYPE_IPV6_SHIFT 27
#define SSSNIC_RSS_TYPE_TCP_IPV4_SHIFT 28
#define SSSNIC_RSS_TYPE_IPV4_SHIFT 29
#define SSSNIC_RSS_TYPE_UDP_IPV6_SHIFT 30
#define SSSNIC_RSS_TYPE_UDP_IPV4_SHIFT 31

#define SSSNIC_RSS_TYPE_SET(val, member) (((u32)(val) & 0x1) << SSSNIC_RSS_TYPE_##member##_SHIFT)
#define SSSNIC_RSS_TYPE_GET(val, member) (((u32)(val) >> SSSNIC_RSS_TYPE_##member##_SHIFT) & 0x1)

enum nic_rss_hash_type {
    SSSNIC_RSS_HASH_TYPE_XOR = 0,
    SSSNIC_RSS_HASH_TYPE_TOEP,

    SSSNIC_RSS_HASH_TYPE_MAX       /* MUST BE THE LAST ONE */
};

#define SSSNIC_RSS_INDIR_SIZE      256
#define SSSNIC_RSS_KEY_SIZE        40

/* *
 * Definition of the NIC receiving mode
 */
#define SSSNIC_RX_MODE_UC          0x01
#define SSSNIC_RX_MODE_MC          0x02
#define SSSNIC_RX_MODE_BC          0x04
#define SSSNIC_RX_MODE_MC_ALL      0x08
#define SSSNIC_RX_MODE_PROMISC     0x10

/* IEEE 802.1Qaz std */
#define SSSNIC_DCB_COS_MAX         0x8
#define SSSNIC_DCB_UP_MAX          0x8
#define SSSNIC_DCB_TC_MAX          0x8
#define SSSNIC_DCB_PG_MAX          0x8
#define SSSNIC_DCB_TSA_SP          0x0
#define SSSNIC_DCB_TSA_CBS         0x1   /* hi1822 do NOT support */
#define SSSNIC_DCB_TSA_ETS         0x2
#define SSSNIC_DCB_DSCP_NUM        0x8
#define SSSNIC_DCB_IP_PRI_MAX      0x40

#define SSSNIC_DCB_PRIO_DWRR       0x0
#define SSSNIC_DCB_PRIO_STRICT     0x1

#define SSSNIC_DCB_MAX_PFC_NUM     0x4

enum sssnic_nic_cmd {
    SSSNIC_CMD_VF_REGISTER = 0, /* only for PFD and VFD */

    /* FUNC CFG */
    SSSNIC_CMD_SET_FUNC_TBL = 5,
    SSSNIC_CMD_SET_VPORT_ENABLE,
    SSSNIC_CMD_SET_RX_MODE,
    SSSNIC_CMD_SQ_CI_ATTR_SET,
    SSSNIC_CMD_GET_VPORT_STAT,
    SSSNIC_CMD_CLEAN_VPORT_STAT,
    SSSNIC_CMD_CLEAR_QP_RESOURCE,
    SSSNIC_CMD_CFG_FLEX_QUEUE,
    /* LRO CFG */
    SSSNIC_CMD_CFG_RX_LRO,
    SSSNIC_CMD_CFG_LRO_TIMER,
    SSSNIC_CMD_FEATURE_NEGO,

    /* MAC & VLAN CFG */
    SSSNIC_CMD_GET_MAC = 20,
    SSSNIC_CMD_SET_MAC,
    SSSNIC_CMD_DEL_MAC,
    SSSNIC_CMD_UPDATE_MAC,
    SSSNIC_CMD_GET_ALL_DEFAULT_MAC,

    SSSNIC_CMD_CFG_FUNC_VLAN,
    SSSNIC_CMD_SET_VLAN_FILTER_EN,
    SSSNIC_CMD_SET_RX_VLAN_OFFLOAD,
    SSSNIC_CMD_SMAC_CHECK_STATE,

    /* SR-IOV */
    SSSNIC_CMD_CFG_VF_VLAN = 40,
    SSSNIC_CMD_SET_SPOOPCHK_STATE,
    /* RATE LIMIT */
    SSSNIC_CMD_SET_MAX_MIN_RATE,

    /* RSS CFG */
    SSSNIC_CMD_RSS_CFG = 60,
    SSSNIC_CMD_RSS_TEMP_MGR, /* TODO: delete after implement nego cmd */
    SSSNIC_CMD_GET_RSS_CTX_TBL, /* TODO: delete: move to ucode cmd */
    SSSNIC_CMD_CFG_RSS_HASH_KEY,
    SSSNIC_CMD_CFG_RSS_HASH_ENGINE,

    SSSNIC_CMD_IPCS_ERR_RSS_ENABLE_OP = 66, /* IP checksum error packets, enable rss quadruple hash */

    /* DPI/FDIR */
    SSSNIC_CMD_ADD_TC_FLOW = 80,
    SSSNIC_CMD_DEL_TC_FLOW,
    SSSNIC_CMD_GET_TC_FLOW,
    SSSNIC_CMD_FLUSH_TCAM,
    SSSNIC_CMD_CFG_TCAM_BLOCK,
    SSSNIC_CMD_ENABLE_TCAM,
    SSSNIC_CMD_GET_TCAM_BLOCK,
    SSSNIC_CMD_CFG_DPI_TABLE_ID,
    SSSNIC_CMD_SET_DPI_EN = 88,
    SSSNIC_CMD_CFG_DPI_MODE,
    SSSNIC_CMD_CFG_DPI_FLUSH,
    SSSNIC_CMD_SET_FDIR_STATUS,
    SSSNIC_CMD_GET_DPI_COUNTER,

    /* PORT CFG */
    SSSNIC_CMD_SET_PORT_ENABLE = 100,
    SSSNIC_CMD_CFG_PAUSE_INFO,

    SSSNIC_CMD_SET_PORT_CAR,
    SSSNIC_CMD_SET_ER_DROP_PKT,

    SSSNIC_CMD_VF_COS,
    SSSNIC_CMD_SETUP_COS_MAPPING,
    SSSNIC_CMD_SET_ETS,
    SSSNIC_CMD_SET_PFC,
    SSSNIC_CMD_QOS_ETS,
    SSSNIC_CMD_QOS_PFC,
    SSSNIC_CMD_QOS_DCB_STATE,
    SSSNIC_CMD_QOS_PORT_CFG,
    SSSNIC_CMD_QOS_MAP_CFG,

    SSSNIC_CMD_TX_PAUSE_EXCP_NOTICE = 118,
    SSSNIC_CMD_INQUIRT_PAUSE_CFG = 119,

    /* MISC */
    SSSNIC_CMD_BIOS_CFG = 120,
    SSSNIC_CMD_SET_FIRMWARE_CUSTOM_PACKETS_MSG,

    /* BOND */
    SSSNIC_CMD_BOND_DEV_CREATE = 134,
    SSSNIC_CMD_BOND_DEV_DELETE,
    SSSNIC_CMD_BOND_DEV_OPEN_CLOSE,
    SSSNIC_CMD_BOND_INFO_GET,
    SSSNIC_CMD_BOND_ACTIVE_INFO_GET,
    SSSNIC_CMD_BOND_ACTIVE_NOTICE,

    /* DFX */
    SSSNIC_CMD_GET_SM_TABLE = 140,
    SSSNIC_CMD_RD_LINE_TBL,

    SSSNIC_CMD_SET_UCAPTURE_OPT = 160, /* TODO: move to roce */
    SSSNIC_CMD_SET_VHD_CFG,

    /* TODO: move to SSSLINK */
    SSSNIC_CMD_GET_PORT_STAT = 200,
    SSSNIC_CMD_CLEAN_PORT_STAT,
    SSSNIC_CMD_CFG_LOOPBACK_MODE,
    SSSNIC_CMD_GET_SFP_QSFP_INFO,
    SSSNIC_CMD_SET_SFP_STATUS,
    SSSNIC_CMD_GET_LIGHT_MODULE_ABS,
    SSSNIC_CMD_GET_LINK_INFO,
    SSSNIC_CMD_CFG_AN_TYPE,
    SSSNIC_CMD_GET_PORT_INFO,
    SSSNIC_CMD_SET_LINK_SETTINGS,
    SSSNIC_CMD_ACTIVATE_BIOS_LINK_CFG,
    SSSNIC_CMD_RESTORE_LINK_CFG,
    SSSNIC_CMD_SET_LINK_FOLLOW,
    SSSNIC_CMD_GET_LINK_STATE,
    SSSNIC_CMD_LINK_STATUS_REPORT,
    SSSNIC_CMD_CABLE_PLUG_EVENT,
    SSSNIC_CMD_LINK_ERR_EVENT,
    SSSNIC_CMD_SET_LED_STATUS,

    SSSNIC_CMD_MAX = 256,
};

/* NIC CMDQ MODE */
enum sssnic_ucode_cmd {
    SSSNIC_UCODE_CMD_MODIFY_QUEUE_CTX = 0,
    SSSNIC_UCODE_CMD_CLEAN_QUEUE_CONTEXT,
    SSSNIC_UCODE_CMD_ARM_SQ,
    SSSNIC_UCODE_CMD_ARM_RQ,
    SSSNIC_UCODE_CMD_SET_RSS_INDIR_TABLE,
    SSSNIC_UCODE_CMD_SET_RSS_CONTEXT_TABLE,
    SSSNIC_UCODE_CMD_GET_RSS_INDIR_TABLE,
    SSSNIC_UCODE_CMD_GET_RSS_CONTEXT_TABLE,
    SSSNIC_UCODE_CMD_SET_IQ_ENABLE,
    SSSNIC_UCODE_CMD_SET_RQ_FLUSH = 10,
    SSSNIC_UCODE_CMD_MODIFY_VLAN_CTX,
    SSSNIC_UCODE_CMD_DPI_HASH_TABLE,
};

#endif
